<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>

</body>
<script>
  var arr = function (s) {
    const ret = [];
    const n = s.length;
    let num = 1;
    for (let i = 0; i < n; i++) {
      if (i === n - 1 || s[i] !== s[i + 1]) {
        if (num >= 3) {
          ret.push([i - num + 1, i]);
        }
        num = 1;
      } else {
        num++;
      }
    }
    return ret;
  };
  console.log(arr(s = "abbxxxxzzy"));
</script>

</html>